package org.example.demo1;

import java.util.concurrent.TimeUnit;

public class lock82 {
    public static void main(String[] args) {
        Phone2 phone2 = new Phone2();
        Phone2 phone3 =  new Phone2();
        new Thread(()->{
            phone2.sendMessage();
        },"A").start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()->{
            phone3.call();
        },"B").start();
    }
}

class Phone2{
    public synchronized void sendMessage(){
        try {
            TimeUnit.SECONDS.sleep(4);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("sendMessage");
    }
    public synchronized void call(){
        System.out.println("call");
    }
    public void hello(){
        System.out.println("hello");
    }
}
